﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VirtualPress.Infrastructure.Entities.Repository;
using VirtualPress.Infrastructure.Entities.Enum;

namespace VirtualPress.Infrastructure.Entities.Entity
{
    public class Expert : IAccessible<T_Expert, Expert>, ILogicEntity<T_Expert, Expert>
    {
        #region Fileds
        public string UserName { get; set; }

        /// <summary>
        /// 称谓
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 学位
        /// </summary>
        public string Degree { get; set; }

        /// <summary>
        /// 擅长领域
        /// </summary>
        public Profession Profession { get; set; }
        /// <summary>
        /// 机构单位
        /// </summary>
        public string Institution { get; set; }

        /// <summary>
        /// 国籍
        /// </summary>
        public string Country { get; set; }

        public string Address { get; set; }

        public string Postcode { get; set; }

        public string Fax { get; set; }

        public string Introduction { get; set; }

        public bool Isvalid { get; set; }
        #endregion

        protected override void Covariant(T_Expert model)
        {
            if (model != null)
            {
                this.Address = model.Address;
                this.Country = model.Country;
                this.Degree = model.Degree;
                this.Fax = model.Fax;
                this.Institution = model.Institution;
                this.Introduction = model.Introduction;
                this.Isvalid = model.Isvalid;
                this.Postcode = model.Postcode;
                this.Title = model.Title;
                this.UserName = model.UserName;
                this.Profession = (Enum.Profession)model.Profession;
            } 
        }

        protected override T_Expert Inverter(Expert model)
        {
            return new T_Expert() { 
                Address=model.Address,
                Country=model.Country,
                Degree=model.Degree,
                Fax=model.Fax,
                Institution=model.Institution,
                Introduction=model.Introduction,
                Isvalid=model.Isvalid,
                Postcode=model.Postcode,
                Title=model.Title,
                UserName=model.UserName,
                Profession=(int)model.Profession
            };
        }

        public Expert Set(T_Expert dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
